
/**
 * Hittable
 * @version 1.0
 * @since 1.0
 * <p>
 * Created by Murphy at 2021/7/9 15:47
 **/

#pragma once

#include "math/Math.hpp"
#include "math/Ray.hpp"
#include "material/Material.hpp"
#include <memory>

namespace Stitches
{
struct HitRecord
{
    Vec3f p;	    //交点
    Vec3f normal;	//法向量
    std::shared_ptr<Material> mat_ptr;
    double t;	    //距离
    bool front_face;


    inline void setFaceNormal(const Ray& r, const Vec3f& outward_normal) {
        front_face = glm::dot(r.direction(), outward_normal) < 0;
        normal = front_face ? outward_normal : -outward_normal;
    }
};

class Hittable
{
public:
    virtual bool hit(const Ray& r, double t_min, double t_max, HitRecord& rec) const = 0;
};

}
